//超时 30分
#include <bits/stdc++.h>
using namespace std;

int lcm(int a, int b) { return a * b / __gcd(a, b); }
int main() {
  int a, n, b, m;
  cin >> n >> m >> a >> b;
  for (int t = max(n, m); t <= max(n, m) + lcm(a, b); ++t) {
    if ((t - n) % a == 0 && (t - m) % b == 0) {
      cout << t;
      return 0;
    }
  }
  cout << "Impossible";
  return 0;
}
